#include "StdAfx.h"
#include "KeepAliveCommander.h"

KeepAliveCommander::KeepAliveCommander(void)
{
}

KeepAliveCommander::~KeepAliveCommander(void)
{
}

int KeepAliveCommander::ProcessCommand( void )
{
	if (!gClientConnStatus.isOnline())
	{
		return COMMAND_INVALID_CONN;
	}
	CMarkup xmlAlive;
	xmlAlive.AddElem(_T("IPIN"));
	xmlAlive.AddChildElem(_T("Type"), CLIENT_ALIVE);
	xmlAlive.AddChildElem(_T("Info"));
	xmlAlive.IntoElem();
	xmlAlive.AddChildElem(_T("Name"), gUserInfo.m_UserName.c_str());
	xmlAlive.AddChildElem(_T("Email"), gUserInfo.m_Email.c_str());
	xmlAlive.AddChildElem(_T("UID"), gUserInfo.m_UID.c_str());
	m_Command = xmlAlive.GetDoc();

	int ConnRsp = SendCommand();
	if (ConnRsp != CONNECTION_OK)
	{
		return COMMAND_CONN_ERROR;
	}
	gClientConnStatus.UpdateAlive();

	return COMMAND_OK;
}